home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / Snippets / Testing & Debugging / BusErrorTest / BusErrTest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-18  |  2.5 KB  |  120 lines  |  [TEXT/MPS ]

  1. /*******************************************************************************
  2.  
  3.     BusErrTest by Cameron
  4.     
  5. *******************************************************************************/
  6.  
  7. #include <String.h>
  8.  
  9. /* Type 1 includes */
  10. #include <Types.h>
  11. #include <QuickDraw.h>
  12.  
  13. /* Type 2 includes */
  14. #include <Controls.h>
  15. #include <Events.h>
  16. #include <Fonts.h>
  17. #include <Memory.h>
  18. #include <Menus.h>
  19. #include <OSUtils.h>
  20. #include <Resources.h>
  21. #include <SegLoad.h>
  22. #include <TextEdit.h>
  23. #include <ToolUtils.h>
  24. #include <Traps.h>
  25.  
  26. /* Type 3 includes */
  27. #include <Desk.h>
  28. #include <Files.h>
  29. #include <OSEvents.h>
  30. #include <Windows.h>
  31.  
  32. /* Type 4 includes */
  33. #include <Dialogs.h>
  34.  
  35. /*  Global Variables  */
  36.  
  37. Str255            WindTitle;
  38. WindowPtr        MyWindow,aWindPtr;
  39. short            err,itemHit;
  40. EventRecord        MyEvent;
  41. Boolean            quit,DrawOn,IsBtn;
  42. Rect            WindRect,Rect1,Rect2;
  43. Point            aPoint;
  44. CursHandle        myCrsr;
  45.  
  46. /*************************************************************************************/
  47. extern void    INSTALLVECTOR();
  48. extern void    CAUSEBUSERR();
  49. extern void    REPLACEVECTOR();
  50.  
  51. /*************************************************************************************/
  52. void    InitMac()
  53. {
  54.     InitGraf(&qd.thePort);
  55.     InitFonts();
  56.     FlushEvents(everyEvent,0);
  57.     InitWindows();
  58.     InitCursor();
  59.     quit = false;
  60.     DrawOn = false;
  61.     IsBtn = false;
  62. }
  63. /*************************************************************************************/
  64. void    DoDraw()
  65. {
  66.     DrawOn = true;
  67.     GlobalToLocal(&MyEvent.where);
  68.     MoveTo(MyEvent.where.h,MyEvent.where.v);
  69.     EraseRect(&WindRect);
  70. }
  71. /*************************************************************************************/
  72. main()
  73. {
  74.     InitMac();
  75.  
  76.     MyWindow = GetNewWindow(2009,nil,(WindowPtr)-1);
  77.     
  78.     if (MyWindow)
  79.     {
  80.         SetPort(MyWindow);
  81.         INSTALLVECTOR();
  82.         while (quit != true)
  83.         {
  84.             if (DrawOn)
  85.             {
  86.                 if (StillDown())
  87.                 {
  88.                     GetMouse (&aPoint);
  89.                     StdLine (aPoint);
  90.                 }
  91.                 else { DrawOn = false; }
  92.             }
  93.             else
  94.             {
  95.                 if (WaitNextEvent(everyEvent,&MyEvent,0,nil))
  96.                 {
  97.                     switch (MyEvent.what)
  98.                     {
  99.                         case mouseDown:
  100.                         {
  101.                             if ((FindWindow (MyEvent.where,&aWindPtr) == inContent)    /* make sure the mouseDown is */
  102.                             && (aWindPtr == MyWindow))                                /* where we want it */
  103.                                 { CAUSEBUSERR(); }
  104.                             else if (FindWindow (MyEvent.where,&aWindPtr) == inGoAway)
  105.                                 { quit = true; }
  106.                             break;
  107.                         }
  108.                         case keyDown:
  109.                         {
  110.                             if ((char)(BitAnd (MyEvent.message,charCodeMask)) == 'q')
  111.                                 { quit = true; }
  112.                             break;
  113.                         }
  114.                     }
  115.                 }
  116.             }
  117.         }
  118.         REPLACEVECTOR();
  119.     }
  120. }